﻿@model  IEnumerable<DashboardGroup>
@{
    var i = 0;
    //  var groups = WebSite.CurrentWeb().IsRoot ? Dashboard.SystemGroups : Dashboard.PersonalGroups;
    var dashboard = Model.SingleOrDefault(g => g.Name.Equals("dashboard", StringComparison.OrdinalIgnoreCase));
    var defaultItems = dashboard == null ? null : dashboard.Items.OrderBy(di => di.Order);
}
@if ((dashboard != null) && (dashboard.Items.Count > 0))
{
    @(Ajax.Dna().CollapsablePanel(dashboard.Name)
                        .Options(opts =>
                        {
                            opts.ShowEffect = jQueryEffects.Blind;
                            opts.HideEffect = jQueryEffects.Scale;
                        })
                            .HtmlAttributes(new { style = "margin-bottom:5px;" })
                            .Header(@<text>
    <div style="padding: 5px;">@Html.Global("RES_DASHBOARD")</div>
    </text>)
                                                .Body(@<text>
    <div style="overflow: auto;">
        @(Ajax.Dna().Menu(dashboard.Name + "-menu")
                                                                        .Options(options =>
                                                                        {
                                                                            options.MenuType = MenuTypes.Vertical;
                                                                        })
                                    .Items(submenus =>
                                    {
                                        foreach (var subitem in defaultItems)
                                        {
                                            submenus.Add(subitem.Title, subitem.NavigationUrl);
                                        }
                                    }).GetHtml())
    </div>
    </text>)
                            .GetHtml())
}
@foreach (var group in Model)
{
    if (group.Name.Equals("dashboard", StringComparison.OrdinalIgnoreCase) || (group.Items.Count == 0)) { continue; }

    var _items = group.Items.OrderBy(di => di.Order);
    @(Ajax.Dna().CollapsablePanel(group.Name)
                                 .Options(opts =>
                                 {
                                     opts.ShowEffect = jQueryEffects.Blind;
                                     opts.HideEffect = jQueryEffects.Scale;
                                 })
                            .HtmlAttributes(new { style = "margin-bottom:5px;" })
                                                .Header(@<text>
    <div style="padding: 5px;">@(!string.IsNullOrEmpty(group.Title) ? group.Title : group.Name)</div>
    </text>)
                                                .Body(@<text>
    <div style="overflow: auto;">
        @(Ajax.Dna().Menu(group.Name + "-menu")
                                                                        .Options(options =>
                                                                        {
                                                                            options.MenuType = MenuTypes.Vertical;
                                                                        })
                                    .Items(submenus =>
                                    {
                                        foreach (var subitem in _items)
                                        {
                                            submenus.Add(subitem.Title, subitem.NavigationUrl);
                                        }
                                    }).GetHtml())
    </div>
    </text>)
                                                .GetHtml()
                            )
    i++;
}